<template>
	<view class="mainpadding2">
		<u-navbar title="商品活動" placeholder autoBack>
			<view class="flexright xiaohui" slot="right" @click="ToClPage(0)">添加</view>
		</u-navbar>
		<view class="flexcenter" v-if="!list.length">
			<view class="placeholderimage" style="margin-top: 100rpx;"></view>
		</view>
		<view class="mainpadding_top ffffff radius" v-for="item in list" :key="item.id">
			<view class="titletext xiaohei bold">{{item.name}}</view>
			<view class="flexbetween margin_top">
				<view class="flexleft">
					<view class="lanlable margin_right1">{{returntype(item.activity_type)}}</view>
					<view class="xiaohui main_size ">已選中<text class="xiaohong">{{item.goods_ids.split(',').length}}</text>件商品</view>
				</view>
				<view class="xiaolan main_size">方式：{{item.type==1?'全部':"最低算"}}</view>
			</view>
			<view class="xiaohuang margin_top main_size">數量：{{item.num}}</view>
			<view class="margin_top hui_text smalltext bold">使用時間<text class="hong_text">{{item.start_time_text}}~{{item.end_time_text}}</text></view>
			<view class="flexright margin_top">
				<view class="flexleft margin_left" @click.stop="ToClPage(item.id)">
					<u-icon name="edit-pen" color="#999" size="16"></u-icon>
					<view class="xiaohei">編輯</view>
				</view>
				<view class="flexleft margin_left" @click.stop="delitem(item.id)">
					<u-icon name="trash" color="#999" size="16"></u-icon>
					<view class="xiaohei">刪除</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			init() {
				this.http.request("/api/Goodsctivitycl/goodsActivityList", 'POST', {
					shop_id: uni.getStorageSync("shop_id"),
					page:1,
					limit:1000,
				}).then(res=>{
					if (res.code == 1) {
						this.list = res.data.data
					} else {
						this.http.toast(res.msg);
					}
				})
				
			},
			ToClPage(id){
				uni.navigateTo({
					url:"/pages/workbench/goodsactive/goodsactivecl?id="+id
				})
			},
			getqyList() {
				this.http.request("/api/hotel/hotelcardIndex", 'GET', {
					shop_id: uni.getStorageSync("shop_id")
				}).then(res => {
					this.list = res.data
				})
			},
			delitem(id) {
				this.http.modal('提示', '確認刪除當前數據嗎？', true, (res) => {
					if (res) {
						this.http.request("/api/Goodsctivitycl/goodsActivityDel", 'GET', {
							id
						}).then(res => {
							if (res.code == 1) {
								this.http.toast("刪除成功")
								this.init()
							} else {
								this.http.toast(res.msg);
							}
						})

					}
				})
			},
			returntype(val){
				if(val==1) return "贈品"
				if(val==2) return "折扣"
				if(val==3) return "抽抽樂"
				if(val==4) return "金額"
			}
		}
	}
</script>

<style>

</style>